package com.nuanshui.heatedloan.web.appsystem;

import com.alibaba.dubbo.config.annotation.Reference;
import com.nuanshui.framework.utils.LogUtil;
import com.nuanshui.heatedloan.baseservice.facade.userapply.OpinionService;
import com.nuanshui.heatedloan.baseservice.model.Opinion;
import com.nuanshui.heatedloan.constant.GlobalParam;
import com.nuanshui.heatedloan.pageable.Pager;
import com.nuanshui.heatedloan.web.ApiController;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created by zxh on 2017/7/3.
 */
@RestController
@RequestMapping("/cms/manage/opinion")
public class OpinionController extends ApiController {

    @Reference(url = GlobalParam.BASESERVICE_DUBBO_SERVER, timeout = GlobalParam.DUBBO_SERVER_TIME_OUT,version = GlobalParam.BASESERVICE_DUBBO_SERVER_VERSION)
    private OpinionService opinionService;

    @RequestMapping("/list")
    public String list(Pager<Opinion> pager){
        pager = opinionService.list(pager);
        return success( pager.asHashMap());
    }

    /**
     * 保存意见反馈信息
     *
     * @param
     * @author zss
     * @date 2017/7/4 19:28
     */
    @RequestMapping("/create")
    public String saveOpinion(Opinion opinion, Errors errors) {
        LogUtil.info(log, "保存反馈的意见信息");
        ControllerHelper.checkException(errors);
        opinionService.saveOpinion(opinion);
        return success(true);
    }

    /**
     * 修改意见反馈信息
     *
     * @param
     * @author zss
     * @date 2017/7/4 19:28
     */
    @RequestMapping("/update")
    public String updateOpinion(Opinion opinion) {
        boolean flag=opinionService.updateOpinion(opinion);
        return success(flag);
    }

    /**
     * 删除意见反馈信息
     *
     * @param
     * @author zss
     * @date 2017/7/4 19:28
     */
    @RequestMapping("/delete")
    public String deleteOpinion(String id) {
        boolean flag=opinionService.deleteOpinion(id);
        return success(flag);
    }

}
